﻿using Airon.DatabaseAccessor;

using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Airon.Dapper.Test.Controllers
{
    [ApiController]
    [Route("[controller]")]
    public class WeatherForecastController : ControllerBase
    {
        private static readonly string[] Summaries = new[]
        {
            "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
        };

        private readonly ILogger<WeatherForecastController> _logger;
        private readonly IDapperRepository _dapperRepository;

        /// <summary>
        /// 这里会将实例注入到 IDapperRepository 中
        /// </summary>
        /// <param name="logger"></param>
        /// <param name="dapperRepository"></param>
        public WeatherForecastController(ILogger<WeatherForecastController> logger,IDapperRepository dapperRepository)
        {
            _logger = logger;
            _dapperRepository = dapperRepository;
        }

        /// <summary>
        /// 这里只是做一个Dapper测试
        /// </summary>
        /// <param name="index"></param>
        /// <returns></returns>
        [HttpGet]
        public  string Gets()
        {
            var result = _dapperRepository.Query("select * from sys_userTable");
            return "123123";

        }
    }
}
